<template>
	<div id="app">
		<router-view></router-view>
	</div>
</template>
<script>
	// import Storage from '@/storage/index.js'
	export default {
		name:'app',
		components:{
			
		},
		data(){
			return{
				
			}
		},
		mounted(){
			//storage.setItem('a',1)
			// this.axios.get('/user/login').then((res)=>{
			// 					this.res = res;
			// })
			if(this.$cookie.get('userId')){
				this.getUser();
				this.getCartCount();
			}
		},
		methods:{
			getUser(){
				this.axios.get('/user').then((res={})=>{
					//保存到vuex里面
					this.$store.dispatch('saveUserName',res.username);
				})
			},
			getCartCount(){
				this.axios.get('/carts/products/sum').then((res)=>{
					//保存到vuex里面
					this.$store.dispatch('saveCartCount',res);
				})
			}
		}
	}
</script>
<style lang="scss">
	@import './assets/scss/reset.scss';
	@import './assets/scss/config.scss';
	@import './assets/scss/button.scss';
</style>
